import React, { useEffect, useState } from 'react'
import '../css/tell.css'
import { useNavigate } from 'react-router-dom'
import axios from 'axios'
import { Button, Modal, Space, Toast, Divider } from 'antd-mobile'


export default function Tell() {
    const navigate = useNavigate()
    const [value, setvalue] = useState('')

    const zhuche = async () => {
        let data = await axios.post('http://127.0.0.1:3000/register', {
            tell: value
        })
       
        console.log(data);
        if (data.data.data.code == 400) {
            Modal.alert({
                content: '账号已存在',
                onConfirm: () => {
                    console.log('Confirmed');
                }

            })
            
        } else {
            Modal.alert({
                content: '账号无误',
                onConfirm: () => {
                    console.log('Confirmed');
                }
            })
            console.log(11);
            navigate('/pwdres?tell='+value)
        }
    }

    return (
        <div className='box-tell'>

            <div className='log-tell'>
                <img src="/8x.png" alt="" onClick={() => {
                    navigate('/login')
                }} />
            </div>

            <div className='head-tell'>
                <h1>你好,</h1>
                <h1>欢迎来到车+!</h1>
            </div>

            <div className='but-tell'>
                <input type="text" placeholder='     请输入手机号' value={value} onChange={(e) => {
                    setvalue(e.target.value)
                }} />
                <p>未注册地手机号验证后自动创建账户</p>
            </div>

            <div className='img-tell' onClick={zhuche}>
                <img src="/7x.png" alt=""  />
            </div>

            <div className='bot-tell'>
                <p>登陆即表明同意 <span>《车+用户协议》</span>和<span>《隐私政策》</span></p>
            </div>
        </div>
    )
}
